<?xml version="1.0" encoding="UTF-8"?>

<!--
    Document   : printFbInfoPDF.xsl
    Created on : November 19, 2013, 11:53 PM
    Author     : Liem
    Description:
        Purpose of transformation follows.
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:f="http://xml.netbeans.org/schema/facebook" exclude-result-prefixes="f"
version="1.0">
    <xsl:output method="xml" indent="yes" encoding="UTF-8"/>

    <!-- TODO customize transformation rules 
         syntax recommendation http://www.w3.org/TR/xslt 
    -->
    <xsl:template match="/">
        <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

            <fo:layout-master-set>

        <!-- layout information -->
                <fo:simple-page-master master-name="simple"
                  page-height="29.7cm"
                  page-width="21cm"
                  margin-top="1cm"
                  margin-bottom="0cm"
                  margin-left="1.5cm"
                  margin-right="1.5cm">
                    <fo:region-body margin-top="3cm"/>
                    <fo:region-before extent="2cm"/>
                    <fo:region-after extent="2cm"/>
                </fo:simple-page-master>
            </fo:layout-master-set>
        <!-- end: defines page layout -->
            <fo:page-sequence master-reference="simple">

      <!-- start fo:flow -->

                <fo:static-content flow-name="xsl-region-before">
                    <fo:block font-size="24pt" font-family="Times New Roman"
                        line-height="24pt"
                        text-align="center" font-style="bold"  padding-top="3pt">
                            Your page info
                    </fo:block>
                    <fo:block>About:
                        <xsl:value-of select="//f:pageAbout"/>
                    </fo:block>
                    <fo:block>Like(s):
                        <xsl:value-of select="//f:likeCount"/>
                    </fo:block>
                    <fo:block>Post(s):
                        <xsl:value-of select="//f:totalPost"/>
                    </fo:block>
                    <fo:block>Comment(s):
                        <xsl:value-of select="//f:totalComment"/>
                    </fo:block>
                </fo:static-content>
                <fo:flow flow-name="xsl-region-body">
                    <fo:block font-size="16pt" font-family="Times New Roman"
                        line-height="24pt" space-after.optimum="15pt" font-style="bold" padding-top="10pt">
                            Top Commenters
                    </fo:block>
                    <fo:table table-layout="fixed" width="100%" border-collapse="separate"
                        font-family="Times New Roman" border-width="0.5mm" border-style="solid"
                        padding="2mm" font-style="italic">
                        <fo:table-column column-width="20mm"/>
                        <fo:table-column column-width="80mm"/>
                        <fo:table-column column-width="20mm"/>
                        <fo:table-body>
                            <fo:table-row>
                                <fo:table-cell >
                                    <fo:block>#</fo:block>
                                </fo:table-cell>
                                <fo:table-cell >
                                    <fo:block>Name</fo:block>
                                </fo:table-cell>
                                <fo:table-cell>
                                    <fo:block>Comment(s)</fo:block>
                                </fo:table-cell>
                            </fo:table-row>
                        </fo:table-body>
                    </fo:table>
                    <fo:table table-layout="fixed" width="100%" border-collapse="separate"
                        font-family="Times New Roman" border-width="0.5mm" border-style="solid"
                        margin-bottom="7mm" padding="2mm">
                        <fo:table-column column-width="20mm"/>
                        <fo:table-column column-width="80mm"/>
                        <fo:table-column column-width="20mm"/>
                        <fo:table-body>
                            <xsl:for-each select="//f:Commenter">
                                <xsl:sort select="f:commentCount" order="descending" data-type="number"/>
                                <fo:table-row border-width="0.8mm" border-style="dashed">
                                    <fo:table-cell>
                                        <fo:block>
                                            <xsl:value-of select="position()"/>
                                        </fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell >
                                        <fo:block>
                                            <xsl:value-of select="f:commenterName"/>
                                        </fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell >
                                        <fo:block>
                                            <xsl:value-of select="f:commentCount"/>
                                        </fo:block>
                                    </fo:table-cell>
                                </fo:table-row>
                            </xsl:for-each>
                        </fo:table-body>
                    </fo:table>
                </fo:flow> 
            </fo:page-sequence> 
        </fo:root>
    </xsl:template>

</xsl:stylesheet>
